package com.strato.datafactory.v1_0_0.filter;


import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


public class RowIdDataFilter extends MapConditionSqlQueryFilter {

	private static final long serialVersionUID = -5573862550998708368L;

	private String rowName;
	
	private List<String> rowIds;
	
	public String getRowName() {
		return rowName;
	}

	public void setRowName(String rowName) {
		this.rowName = rowName;
	}

	public List<String> getRowIds() {
		return rowIds;
	}

	public void setRowIds(List<String> rowIds) {
		this.rowIds = rowIds;
	}

	public Map<String,Object> getConditionValues() {
		Map<String,Object> m=super.getConditionValues();
		if(m==null){
			m=new HashMap<String,Object>();
		}
		if(rowIds!=null){
			StringBuffer buf=new StringBuffer();
			for(Iterator<String> iter=rowIds.iterator();iter.hasNext();){
				String rowId=iter.next();
				buf.append("'").append(rowId).append("'").append(",");
			}
			buf.deleteCharAt(buf.length()-1);
			m.put(rowName, buf.toString());
		}
		return m;
	}

}
